unit dgAddStack ;

interface

uses
   Windows,
   Messages,
   SysUtils,
   Variants,
   Classes,
   Graphics,
   Controls,
   Forms,
   Dialogs,
   StdCtrls,
   TntStdCtrls,
   SpTBXEditors,
   SpTBXControls,
   TBXDkPanels,
   uBasic,
   uObjects,
   GDIPOBJ,
   GDIPAPI ;

type
   TdlgAddStack = class( TForm )
      SpTBXPanel1 : TSpTBXPanel ;
      btnOK : TSpTBXButton ;
      btnCancel : TSpTBXButton ;
      SpTBXGroupBox3 : TSpTBXGroupBox ;
      edLabel : TSpTBXEdit ;
      SpTBXGroupBox2 : TSpTBXGroupBox ;
      edDesignator : TSpTBXButtonEdit ;
      SpTBXGroupBox5 : TSpTBXGroupBox ;
      seDiameter : TSpTBXSpinEdit ;
      cbNoHole : TSpTBXCheckBox ;
      SpTBXGroupBox1 : TSpTBXGroupBox ;
      seOffsetX : TSpTBXSpinEdit ;
      seOffsetY : TSpTBXSpinEdit ;
    procedure btnOKClick(Sender: TObject);
   private
      fStack : TMedaStack ;
      procedure SetStack( const Value : TMedaStack ) ;
      procedure SetTitle( const Value : string ) ;
   public
      property Title : string write SetTitle ;
      property Stack : TMedaStack read FStack write SetStack ;
   end ;

implementation

{$R *.dfm}

{ TdlgAddStack }

procedure TdlgAddStack.btnOKClick(Sender: TObject);
begin
   if assigned( fStack ) then begin
      if cbNoHole.Checked then
         fStack.Hole := 0.0
      else
         fStack.Hole := seDiameter.Value ;
      fStack.Name := edLabel.Text ;
      fStack.Designator := edDesignator.Text ;
      fStack.Offset := MakePoint( seOffsetX.Value, seOffsetY.Value ) ;
   end ;
end;

procedure TdlgAddStack.SetStack( const Value : TMedaStack ) ;
begin
   FStack := Value ;
   if assigned( fStack ) then begin
      cbNoHole.Checked := fStack.Hole < 10E-10 ;
      seDiameter.Value := fStack.Hole ;
      edLabel.Text := fStack.Name ;
      edDesignator.Text := fStack.Designator ;
      seOffsetX.Value := fStack.Offset.X ;
      seOffsetY.Value := fStack.Offset.Y ;
   end ;
end ;

procedure TdlgAddStack.SetTitle( const Value : string ) ;
begin
   Caption := Value ;
end ;

end.

